home *** CD-ROM | disk | FTP | other *** search
/ Java Primer Plus / Java Primer Plus (Waite Group Proess)(1996).iso / chapter10 / abstract.java next >
Text File  |  1995-12-31  |  548b  |  31 lines

  1.     /* The abstract class Shape - it cannot be instantiated */
  2.     abstract class Shape {
  3.  
  4.        abstract public void drawme();    // abstract method
  5.  
  6.        public void printmsg() {
  7.  
  8.         System.out.println("in the abstract class");
  9.         }
  10.  
  11.          }
  12.  
  13.     /* class rectangle - it MUST override drawme() */
  14.     class rectangle extends Shape {
  15.  
  16.         int width, height;
  17.  
  18.         public rectangle(int width,int height) {
  19.             this.width = width;
  20.             this.height = height;
  21.             }
  22.  
  23.         public void drawme() {        // overrider
  24.  
  25.             // code to draw a rectangle
  26.  
  27.             }
  28.         }
  29.  
  30.  
  31.